﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

	<meta http-equiv="content-type" content="text/html; charset=utf-8"/>    
	<title>welcome to Yes or No!!</title>    
    
     <style type = "text/css">
		  body{
			  font-family: Futura;
			  background-image: gray;
		  }
		  p{
			  color: maroon;
		  }
		  h1{
			  font-family: Zapfino;
			  color: gray;
			  font-size : 40;
			
		  }
	  </style>
    <script src="../googleAnalytics.js" type="text/javascript"></script>   
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAHHQwI7Yl5wVURxsuvbc5jxSGEnaH5YVeejJ-C3XyzEKP1PH33BRW7_7WPjfpaLunAahTOD7Gd37cBw" type="text/javascript"></script>   
	<script type"text/javascript"> 
		window.onload=initialize;
		window.onunload=GUnload;
		
		
		
		var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
  		var myOptions = {
    		zoom: 4,
    		center: myLatlng,
    		mapTypeId: google.maps.MapTypeId.ROADMAP
  		}
  		var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
  	
		var control;
		var geocoder = null;
		var bounds = new GLatLngBounds();
 
 
		// Very Basic Map setup on canvas
		function initialize() {      
			if (GBrowserIsCompatible()) {        
				map = new GMap2(document.getElementById("map_canvas"));        
				map.setCenter(new GLatLng(document.q.xpoint.value, document.q.ypoint.value), 13);    
				map.enableScrollWheelZoom();
 				var marker = new GMarker(map.getCenter()); 
				map.addOverlay(marker);
				document.q.address.value=response.Placemark[0].address; 
			}    
		}
 
	
 
	</script> 

</head>
<body>
	<?php
		$dbc = mysqli_connect( 'localhost' ,'root' , '', 'teresa' ) or die( 'Error connecting to MySQL server.');		
		$message_id = $_GET['message_id'];

		$query = "SELECT * FROM teresa_message WHERE message_id = '$message_id'";
		$data = mysqli_query( $dbc , $query) or die('ERROR queerying database.');

		$row = mysqli_fetch_array( $data );
		$subject = $row['subject'];
		$message = $row['message'];
		$response_id = $row['response_id'];
		$location_x = $row['location_x'];
		$location_y = $row['location_y'];
		$address = $row['address'];

		echo $response_id;
		echo '<strong>Subject :'. $subject . '</strong></br>';
		echo 'message : ' . $message . '</br>';
		


		$query = "SELECT * FROM teresa_message WHERE response_id = '$response_id'";
		$data = mysqli_query( $dbc , $query) or die('ERROR queerying database.');
		
		$count = 0;
	
		echo '<p><strong>Helper List : </strong></br><p>';

		while( $row = mysqli_fetch_array( $data ) ){
			$response = $row['response'];
			$reciever = $row['reciever'];
			if( $response == 'yes' ){ 
				echo '<p>' . $reciever . '</br></p>';			 
				$count = $count + 1;
			}
		}
		echo '<p>Helper Count : ' . $count . '</p>';
		
	?>
	<form name="q"> 
		<table>
			<tr>
				<td>
					<p>GLatlng :</p>
				</td>
				<td>
					<input type="text" id="xpoint" name="xpoint" value="<?php echo $location_x ?>">
					<input type="text" id="ypoint" name="ypoint" value="<?php echo $location_y ?>">
				</td>
				
			</tr>
			<tr>
				<td>
					<p>Address :</p>
				</td>
				<td>
					<textarea name="address" id="address" rows="2" cols="30"  ><?php echo $address ?></textarea>
				</td>
				
			</tr>
		</table>	
		<table>	
			<tr>		
				<td>
					<div id="map_canvas" style="margin: 1em 1em; width:400px; height: 300px; float:left"></div> 
					<div id="status"></div>		
				</td>
			</tr>
			<tr>
				<td><a href="outbox.php">Return to inbox</a></td>
			</tr>
		</table>	
	</form> 	
	
</body>
</html>
